import 'dart:async';

import 'package:flutter/foundation.dart';

/// https://stackoverflow.com/a/55119208
class Debouncer {
  final int milliseconds;
  Timer? _timer;

  Debouncer({required this.milliseconds});

  run(VoidCallback action) {
    _timer?.cancel();

    _timer = Timer(Duration(milliseconds: milliseconds), action);
  }
}
